home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <dos.h>
-
- #define DOS 0x21
- #define NETBIOS 0x5C
-
- /* structure to allow easy access to both segment and offset portions of
- far pointers */
- struct SEGOFFS {
- unsigned offs;
- unsigned seg;
- };
-
- typedef union POINTER {
- unsigned char *ptr;
- struct SEGOFFS l;
- }POINTER;
-
-
- /* netbios_present ********************************************************************
- Determine if a netbios has been loaded
- *****************************************************************************/
- int netbios_present() {
- union REGS regs;
- struct SREGS sregs;
- unsigned char ncb[65];
- POINTER ptr;
-
-
- /* make an NCB with an illegal NETBIOS command */
- memset(ncb,0,65);
- ncb[0] = 0x7F;
- ptr.ptr = ncb;
-
- /* try calling the illegal function */
- regs.h.al = 0;
- sregs.es = ptr.l.seg;
- regs.x.bx = ptr.l.offs;
- int86x(NETBIOS,®s,®s,&sregs);
-
- /* see if NETBIOS caught it and returned an error */
- return(regs.h.al != 0);
- }
-
- /* display machine name */
- int main(argc,argv) {
- union REGS regs;
- struct SREGS sregs;
- char name[16];
- POINTER ptr;
-
- if (!netbios_present()) {
- puts("Netbios not loaded.");
- return(1);
- }
-
- ptr.ptr = name;
- regs.x.ax=0x5E00; /* get machine name function */
- sregs.ds = ptr.l.seg;
- regs.x.dx = ptr.l.offs;
-
- intdosx(®s,®s,&sregs);
-
- if (!regs.h.ch) {
- puts("Your machine is nameless!");
- return(2);
- }
-
-
-
-
- printf("Your machine is %s\n",name);
- }
-
-
-
-
-
-
-